package com.dnjn.happiness.biz.api.factory;

import com.dnjn.happiness.biz.api.RemoteTrainingService;
import com.dnjn.happiness.common.core.domain.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;


@Component
public class RemoteTrainingFallbackFactory implements FallbackFactory<RemoteTrainingService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteTrainingFallbackFactory.class);

    @Override
    public RemoteTrainingService create(Throwable throwable) {
        log.error("调用培训服务失败：{}" + throwable.getMessage());
        return new RemoteTrainingService() {
            @Override
            public R<Integer> getTraingRecordNotJoin(Long userId,String time, String source) {
                return R.fail("获取培训信息失败：{}" + throwable.getMessage());
            }

            @Override
            public R<Integer> getTraingRecordYesJoin(Long userId,String time, String source) {
                return R.fail("获取培训信息失败：{}" + throwable.getMessage());
            }
        };
    }
}
